package com.example.skyline.common;


import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result {
    public static final String CODE_SUCCESS = "200";

    public static final String CODE_SUCCESS_AUTO_ERROR = "401";

    public static final String CODE_SYS_ERROR = "500";


    private String code;
    private String msg;
    private Object data;

    public static Result success(){
        return new Result(CODE_SUCCESS,"请求成功",null);
    }

    public static Result success(Object data){
        return new Result(CODE_SUCCESS,"请求成功",data);
    }

    //请求失败
    public static Result error(String code, String msg){
        return Result.builder().code(code).data(null).msg(msg).build();
    }

    public static Result error(String msg){
        return Result.builder().code(CODE_SYS_ERROR).data(null).msg(msg).build();
    }
}
